import store from '@/store'
export function setOem() {
  // return new Promise((resolve, reject) => {
  //   // const host = location.host
  //   // host = "sh.anshanpay.com"; // 测试用
  //   // case 'localhost:9528':
  //   const activeOem = 'default'
  //   const activeFavicon = `./static/oem/${activeOem}/favicon.ico`
  //   store.state.oem.oemConfig.activeOem = activeOem
  //   addFaviconLink(activeFavicon)
  // })
  return new Promise((resolve, reject) => {
    const host = location.host
    let activeOem = 'default'
    switch (host) {
      case 'https://marketing-merch-test.fuhuiba.ltd':
        activeOem = 'oemActive'
        break
    }
    const activeFavicon = `./static/oem/${activeOem}/favicon.ico`
    store.state.oem.oemConfig.activeOem = activeOem
    addFaviconLink(activeFavicon)
  })
}

function addFaviconLink(url) {
  var doc = document
  var link = doc.createElement('link')
  link.setAttribute('rel', 'shortcut icon')
  link.setAttribute('href', url)
  var heads = doc.getElementsByTagName('head')
  if (heads.length) {
    heads[0].appendChild(link)
  } else {
    doc.documentElement.appendChild(link)
  }
}
